#let long-underline(left: 0, right: 0, stroke: black, fake-text: "a ", content, ..args) = {
  let lspace(n) = {
    set text(fill: rgb("00000000"))
    underline(stroke: stroke, evade: false, fake-text * n, ..args)
  }
  if left > 0 {
    lspace(left)
  }
  underline(..args, content)
  if right > 0 {
    lspace(right)
  }
}

#let project(title: "", course: "", authors: (), teacher: "", body) = {
  set text(
    font: "Source Han Sans",
    lang: "zh",
    region: "cn",
  )
  set par(justify: true)

  set heading(numbering: (..args) => {
    let nums = args.pos()
    if nums.len() == 1 {
      return numbering("一、", ..nums)
    } else if nums.len() == 2 {
      return numbering("1.", nums.at(1))
    } else if nums.len() == 3 {
      return numbering("(1)", nums.at(2))
    } else if nums.len() == 4 {
      return numbering("a.", nums.at(3))
    }
  })

  show raw: it => {
    set text(font: ("FiraMono Nerd Font Mono", "Source Han Sans"))
    align(
      center,
      block(
        width: 95%,
        align(
          left,
          block(
            width: 100%,
            fill: rgb(248, 248, 248),
            radius: 3pt,
            inset: 15pt,
            it,
          ),
        ),
      ),
    )
  }


  align(center)[
    #text(size: 20pt, weight: "bold", font: "Source Han Sans")[
      北京邮电大学计算机学院（国家示范性软件学院）

      #underline("2023-2024") 学年第#underline(" 2 ")学期实验报告
    ]

    #v(10em)
    #set text(
      14pt,
      weight: "bold",
    )

    #block(width: 70%)[
      #align(left)[
        #grid(
          gutter: 3em,
          [课程名称：#long-underline(left: 5,right:7, text(font: "Source Han Serif",course), offset: 1.6pt)],
          [实验名称：
          
          #long-underline(left: 1,right:1, text(font: "Source Han Serif",title), offset: 1.6pt)],
          "实验完成人：",
          grid(
            gutter: 1.6em,
            ..authors.map(author => align(center)[
              姓名：#long-underline(left: 2,right:2, text(font: "Source Han Serif",author.name) , offset: 1.6pt)
              #h(0.5em)学号：#long-underline(left: 2,right:2, text(font: "Source Han Serif",author.number), offset: 1.6pt)
              #h(0.5em)
            ]),
          ),
          [指导教师：#long-underline(left: 8,right:9, text(font: "Source Han Serif",teacher), offset: 1.6pt)],
        )
      ]
    ]

    #v(9em)
    日#h(1em)期：#datetime.today().display("[year]  年  [month]  月  [day]  日")
  ]



  pagebreak()

  show outline: it => {
    text(size: 13pt)[#it]
  }

  outline(indent: auto)

  pagebreak()

  set text(font: "Source Han Serif")

  set page(
    numbering: "1",
    number-align: center,
  )
  counter(page).update(1)


  par(leading: 1em)[
    #show heading: set block(spacing: 1.2em)
    #body
  ]
}